import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import get from '@dfeidao/atom-web/local/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';
import set from '@dfeidao/atom-web/local/set';

export default async function a001(fd: IFeidaoAiBrowserComponent, n: string) {
	// todo
	const no = get(fd, 'no') as string;
	const resno = n as string;

	if (no) {
		const res = await nodejs<Array<{}>>('device-type/zj-000007/s001', {
			filter: {
				equip_type_no: no
			}
		});
		render(fd, res, p001, 'p001', 'inner');
	} else {
		const res = await nodejs<Array<{}>>('device-type/zj-000007/s001', {
			filter: {
				equip_type_no: resno
			}
		});
		render(fd, res, p001, 'p001', 'inner');
	}

	const up = fd.data.node.querySelector<HTMLDivElement>('[data-id="update"]');
	set_node_cls(up, 'display-n', false);

	set(fd, 'resno', resno);
}
